<template>
  <div style="padding: 15px;">
    <div style="margin-bottom: 15px;">
      <Input style="width: 200px;" placeholder="请输入权限名称"/>
      <Button @click="searchOrg" type="success">搜索</Button>
      <Button @click="addPermission" type="primary" style="float: right;">添加权限</Button>
    </div>
    <Table border ref="selection" :columns="columns" :data="tableData"></Table>
    <Modal v-model="permissionModal" :title="modalTitle" @on-ok="ok" @on-cancel="cancel">
      <Form :model="orgTeacherForm" :label-width="80">
        <FormItem label="权限名称">
          <Input v-model="orgTeacherForm.name" vaule="" placeholder="请输入教师姓名"/>
        </FormItem>
        <FormItem label="接口路径">
          <Input v-model="orgTeacherForm.name" vaule="" placeholder="请输入教师姓名"/>
        </FormItem>
        <FormItem label="上级权限名">
          <Select v-model="orgTeacherForm.orgBelong">
            <Option value="item.userName">权限一</Option>
            <Option value="item.userName">权限二</Option>
          </Select>
        </FormItem>
        <FormItem label="序号">
          <InputNumber :max="10" :min="1" v-model="orgTeacherForm.sequence"></InputNumber>
        </FormItem>
        <FormItem label="图标">
          <Input v-model="orgTeacherForm.name" vaule="" placeholder="请输入图标class名称"/>
        </FormItem>
        <FormItem label="状态">
          <i-switch size="large">
            <span slot="open">启用</span>
            <span slot="close">禁用</span>
          </i-switch>
        </FormItem>
      </Form>
    </Modal>
  </div>
</template>

<script>
export default {
  name: 'index',
  data () {
    return {
      orgTeacherForm: {},
      orgAdmin: '',
      orgAdminList: [
        {
          userName: 'zhumo',
          realName: '朱墨'
        },
        {
          userName: 'caimingxu',
          realName: '蔡明旭'
        }
      ],
      columns: [
        {
          type: 'selection',
          width: 60,
          align: 'center'
        },
        {
          title: '权限名称',
          key: 'name',
          align: 'center'
        },
        {
          title: '接口路径',
          key: 'userName',
          align: 'center'
        },
        {
          title: '上级权限名',
          key: 'createTime',
          align: 'center',
          width: 150
        },
        {
          title: '序号',
          key: 'operator',
          align: 'center'
        },
        {
          title: '图标',
          key: 'operator',
          align: 'center'
        },
        {
          title: '状态',
          key: 'status',
          width: 120,
          align: 'center',
          render: (h, params) => {
            const row = params.row
            const color = row.status === '1' ? 'primary' : row.status === '0' ? 'error' : ''
            const text = row.status === '1' ? '正常' : row.status === '0' ? '禁用' : ''
            return h('Tag', {
              props: {
                type: 'dot',
                color: color
              }
            }, text)
          }
        },
        {
          title: '操作',
          key: 'action',
          width: 150,
          align: 'center',
          render: (h, params) => {
            return h('div', [
              h('Button', {
                props: {
                  type: 'primary',
                  size: 'small'
                },
                style: {
                  marginRight: '5px'
                },
                on: {
                  click: () => {
                    this.show(params.index)
                  }
                }
              }, '编辑'),
              h('Button', {
                props: {
                  type: 'error',
                  size: 'small'
                },
                style: {
                  marginRight: '5px'
                },
                on: {
                  click: () => {
                    this.show(params.index)
                  }
                }
              }, '删除')
            ])
          }
        }
      ],
      tableData: [
        {
          name: '朱自清',
          orgBelong: '杭州钱塘外国语学校',
          userName: 'zhuziqing',
          phone: '13578869443',
          famousTeacher: '1',
          createTime: '2018-11-15 12:10:11',
          updateTime: '2018-11-15 12:10:11',
          operator: 'admin',
          status: '1'
        },
        {
          name: '袁世凯',
          orgBelong: '北平家里蹲大学',
          userName: 'littleyuan',
          phone: '13102189443',
          famousTeacher: '0',
          createTime: '2018-11-15 12:10:11',
          updateTime: '2018-11-15 12:10:11',
          operator: 'admin',
          status: '0'
        }
      ],
      cityList: [
        {
          value: 'Zhe Jiang',
          label: '浙江省'
        },
        {
          value: 'An Hui',
          label: '安徽省'
        },
        {
          value: 'Shanghai',
          label: '上海市'
        },
        {
          value: 'Beijing',
          label: '北京市'
        },
        {
          value: 'He Bei',
          label: '河北省'
        },
        {
          value: 'Jiang Su',
          label: '江苏省'
        }
      ],
      areaModel: '',
      permissionModal: false,
      modalTitle: ''
    }
  },
  methods: {
    addPermission () {
      this.permissionModal = true
      this.modalTitle = '添加权限'
    },
    searchOrg () {
    }
  }
}
</script>

<style scoped>

</style>
